#include <stdio.h>

#define N 8
#define MAXLINE 1000

int getline2(char line[], int maxline);
void detab(char out[], char in[]);

int main()
{
    char in[MAXLINE];
    char out[MAXLINE];
    int len;

    while ((len = getline2(in, MAXLINE)) > 0)
    {
        printf("in = %s", in);
        detab(out, in);
        printf("out = %s\n", out);
    }

    return 0;
}

int getline2(char line[], int maxline)
{
    int c, i;

    for (i = 0; i < maxline - 1 && (c = getchar()) != EOF && c != '\n'; i++)
    {
        line[i] = c;
    }
    if (c == '\n')
    {
        line[i] = c;
        i++;
    }
    line[i] = '\0';
    return i;
}

void detab(char out[], char in[])
{
    int i, j, tmp, tcnt = 0;
    for (i = 0; (in[i] != '\0') && (in[i] != '\n'); i++)
    {
        if (in[i] != '\t')
        {
            if (tcnt % (N + 1) == 0)
            {
                out[tcnt++] = '|';
            }

            out[tcnt++] = in[i];
        }
        else
        {
            tmp = tcnt % (N + 1);
            for (j = 0; j < N + 1 - tmp; j++)
            {
                out[tcnt++] = ' ';
            }
            out[tcnt++] = '|';
        }
    }

    tmp = tcnt % (N + 1);
    for (j = 0; j < N + 1 - tmp; j++)
    {
        out[tcnt++] = ' ';
    }
    out[tcnt++] = '|';

    out[tcnt] = '\0';
}